#include "StdAfx.h"
#include "EffectFactory.h"
#include "PeriodicDamageEffect.h"


EffectFactory::EffectFactory()
{
	m_pPeriodicDamagePool = new CMemoryPoolFactory<PeriodicDamageEffect>;
}

EffectFactory::~EffectFactory()
{
	Release();

	SAFE_DELETE( m_pPeriodicDamagePool );
}

VOID EffectFactory::Release()
{
	if( m_pPeriodicDamagePool )		m_pPeriodicDamagePool->Release();
}

VOID EffectFactory::Init( DWORD dwMaxPoolSize )
{
	m_pPeriodicDamagePool->Initialize( dwMaxPoolSize, dwMaxPoolSize/2+1 );
}

BaseEffect* EffectFactory::AllocEffect( eFIELDEFFECT_TYPE eEffectType )
{
	BaseEffect *pEffect = NULL;

	switch( eEffectType )
	{
	case EFFECT_TYPE_PERIODIC_DAMAGE:
		pEffect = m_pPeriodicDamagePool->Alloc();		break;
	default:
		ASSERT(! "EffectFactory : [AllocEffect] Invalid eEffectType! \n" );
	}

	return pEffect;
}


VOID EffectFactory::FreeEffect( BaseEffect* pEffect )
{
	switch( pEffect->GetStateID() )
	{
	case EFFECT_TYPE_PERIODIC_DAMAGE:
		m_pPeriodicDamagePool->Free( (PeriodicDamageEffect*)pEffect );	break;

	default:				
		ASSERT(! "EffectFactory : [FreeEffect] Invalid eEffectType! \n" );
	}
}






















